<?php 
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require_once("include/config.php");
require_once("include/httpUtil.php");
header("Content-type: text/html; charset=utf-8");
define('SCRIPT','ad_list');
if(!$_COOKIE['userid']){
    echo "<script type='text/javascript'>location.href='mlogin.php';</script>";
    exit;
}

if($_GET['act']=='add'){
    $addtime=date('Y-m-d H:i:s');
    $ywyuedu=$_POST['ywyuedu'];
	$ywyuedu1=rtrim($ywyuedu,",");	
    $title1=$_POST['title'];
    $ziwop1=$_POST['ziwop'];
    $shoparea=$_POST['city'];
    $moneyy=$_POST['num'];
    $fenlei=$_POST['fenlei'];	
	
$sql="insert into tbl_skill_details values(
        0,
        '".$_COOKIE['userid']."',		
        '".$title1."',
        '".$ziwop1."',
        '".$ywyuedu1."',
        '".$fenlei."',		
        0,
        0,
        '".$shoparea."',		
        '".$moneyy."',
        0,
        '".$addtime."',		
	    0
        )";
    $query=mysql_query($sql);

	
	
        if($query){
             echo "<script type='text/javascript'>alert('发布成功');location.href='index.php';</script>";
        }else{
            echo "<script type='text/javascript'>alert('发布失败');location.href='index.php';</script>";
        }
}
?> 
<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
  <title><?=$_COOKIE['shuyu']?>发布宝贝-出售-众晒网</title>
  <meta name="renderer" content="webkit">
    <!-- Set render engine for 360 browser -->


  <!-- No transcoding by search engine-->
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp"/>
  <link rel="stylesheet" href="/ui/amui/css/amazeui.min.css">
    <link rel="stylesheet" href="/ui/amui/css/app.css">
<script src="/ui/amui/js/jquery.min.js"></script>
<script src="/ui/amui/js/amazeui.min.js"></script>
<link rel="stylesheet" href="/ui/amui/di/dist/amazeui.address.min.css">
<script src="/ui/amui/di/dist/iscroll.min.js">
</script> <script src="/ui/amui/di/dist/address.js"></script>
<script type="text/javascript" src="/ui/layer/mobile/layer.js"></script>  
</head>
<body ontouchend="Aaa()" style="margin-top:-25px">
<div class="am-alert am-alert-warning" style="margin-top:23px;background-color: #ffffff;"> 
  <button type="button" onclick="disp_confirm()" class="am-close" style="color: black;">&times;</button>
  <p style="color: black;text-align: center;">技能发布</p>
</div>
<form action="?act=add" method="post" id="signupok" name="addform"  enctype="multipart/form-data"   onSubmit="return beforeSubmit(this);"> 
  <div style="display:none">
            <input type="hidden" name="infoid" value="<?php echo time().rand(100,999);?>" />                   
        </div>  
       <div >
       <center>
            <div style="width:50px;height:80px" onclick="getElementById('inputfile').click()">
            <div style="float:left;width:60px;height:73px;margin-left:-26px;" >
            <img src="/ui/image/圆角矩形1141拷贝3@3x.png"  style="width:67px;height:67px" alt="" title="添加照片">
            <input type="file" accept="image/*" multiple="multiple" id="inputfile" style="height:0;width:0;z-index: -1; position: absolute;left: 10px;top: -100px;"/>
            </div>
            </div>	
        </center>  
        </div>
            <div id="feedback"  value="feedback" name="ywyuedu" style="margin-bottom:10px">
            <input style=" display:none" id="srcall" name="ywyuedu">
        </div>
<div class="am-input-group am-input-group-warning am-padding-sm" style="width:100%;margin:0">
  <input type="text" name="title" style="border-radius:5px 5px 5px 5px;top:-18px;" class="am-form-field" placeholder="请清晰明确的标题更吸引人">
</div>

<div class="am-input-group am-input-group-warning am-padding-sm am-round" style="width:100%;margin-top:-30px">

  <textarea name="ziwop" id="ziwop" type="text" rows="5" cols="7" style="border-radius:5px 5px 5px 5px;height:185px;" class="am-form-field"  placeholder="请输入您的收费标准.服务流程.服务保障等。详细的服务介绍可以吸引更多客户阅读"></textarea>
</div>
<center>
			<div style="width:100%">
			<fieldset class="am-form-set" style="width:63%;margin-top:-23px;height:33px">
				<input type="text" name="city" readonly style="top:0px;padding:.55em;border:0;background-color:rgba(255, 255, 255, 0);">
			</fieldset>			
			<button type="button" id="address1" class="am-btn am-btn-block am-margin-bottom-sm"	style="width:89%;float:left;margin-left:5%;margin-top:-15px;background-color: #efa100;color:white;">
				<i class="am-icon am-icon-home"></i> 请点击这里选择地址
			</button>

			</div>
			
</center>
<center>
<div>
<select name="fenlei" id="sheng" data-am-selected="{btnWidth: '89%', btnSize: 'sm', btnStyle: 'warning',dropUp: 1}">
  <option value ="0">顶级分类</option>
   <?php 
       $sql_cat = "select * from tbl_skill_catgroy where status=0  order by id asc";
       $query_cat = mysql_query($sql_cat);
       while ($row_cat=mysql_fetch_array($query_cat)) { 
   ?> 
       <option value ="<?php echo $row_cat['id']; ?>"><?php echo $row_cat['cat_name']; ?></option>
   <?php } ?>  
</select>

</div>
</center>
<br/>

<div class="am-input-group" style="width: 89%;margin-left: 5%;">
  <span class="am-input-group-label">服务收费</span>
  <input type="text" name="num" id= "shuliang"  class="am-form-field" placeholder="请输入价格">
  <span class="am-input-group-label">元</span>
</div>



<center>
<button type="submit" onclick="clicimg()" class="am-btn am-btn-warning am-padding-sm" style="width:89%;">确认发布</button>
</br>
</form>
</center>

<div style="margin-top:15px;"> </div>
<script type="text/javascript">
function beforeSubmit(form){

    if (document.addform.ywyuedu.value==""){
	   layer.open({
    content: '请上传三张以上照片'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });

        return false;
    }

    if (document.addform.title.value==""){
	   layer.open({
    content: '请清晰明确的标题更吸引人'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });
		
        return false;
    }
    if (document.addform.ziwop.value=="" ){
	   layer.open({
    content: '请填写详细说明！'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });
        return false;
    }
		    if (document.addform.ziwop.value.length < 12){
	   layer.open({
    content: '文字不少于12字'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });
        return false;
    }
    if (document.addform.city.value=="" ){
	   layer.open({
    content: '请选择城市！'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });
        return false;
    }    
    if (document.addform.fenlei.value=="0" ){
	   layer.open({
    content: '请选择分类！'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });
        return false;
    }

    if (document.addform.num.value=="" ){
	   layer.open({
    content: '请填写数量！'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });
        return false;
    }    
    document.addform.submit();
    return true;    
}

</script> 
		<script type="text/javascript">
			$(function() {

				//	自定义输出
				$("#address1").address({
					customOutput: true,
					selectNumber: 2,
					selectEnd: function(json,address) {
						for(var key in json) {
							$("#signupok").find("input[name='" + key + "']").val(json[key]);
						}
					}
				}).on("provTap",function(event,activeli){
					console.log(activeli.text());
				}).on("cityTap",function(event,activeli){
					console.log(activeli.text());
				})
			});
		</script>
<script type="text/javascript">
$(document).ready(function(){
    //响应文件添加成功事件
    $("#inputfile").change(function(){
        //创建FormData对象
        var data = new FormData();
        //为FormData对象添加数据
        $.each($('#inputfile')[0].files, function(i, file) {
            data.append('upload_file'+i, file);
        });
        $(".loading").show();   //显示加载图片
        //发送数据
        $.ajax({
            url:'submit_form_process.php',
            type:'POST',
            data:data,
            cache: false,
            contentType: false,     //不可缺参数
            processData: false,     //不可缺参数
            success:function(data){
                data = $(data).html();
                //alert(data);
                //第一个feedback数据直接append，其他的用before第1个（ .eq(0).before() ）放至最前面。
                //data.replace(/&lt;/g,'<').replace(/&gt;/g,'>') 转换html标签，否则图片无法显示。
                if($("#feedback").children('img').length == 0) $("#feedback").append(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
                else $("#feedback").children('img').eq(0).before(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
                $(".loading").hide();   //加载成功移除加载图片
            },
            error:function(){
                alert('上传出错');
                $(".loading").hide();   //加载失败移除加载图片
            }
        });
    });
});
</script>
<script type="text/javascript">
    function clicimg(){
        var legth=document.getElementsByName('thissrc');
        var srca="";
        for(var i=0;i<legth.length;i++){
            srca+=legth[i].src;
            srca+=",";
        }
        document.getElementById('srcall').value=srca;
    }
</script>	
<script type="text/javascript">
$(function () {  
            //防止页面后退  
            history.pushState(null, null, document.URL);  
            window.addEventListener('popstate', function () {  
                    history.pushState(null, null, document.URL);  
            });  
        }) 
</script>
<script type="text/javascript">
function disp_confirm()
  {
  var r=confirm("确定返回将不保存您编辑的内容")
  if (r==true)
    {
     window.location.href="index.php"
    }
  }
</script>	
</body>
</html>
